// ==UserScript== // @name 宝可梦点击(Poke Clicker)辅助脚本 野外离线战斗模块 // @namespace PokeClickerHelper // @version 0.4.0 // @description 仅计算离线野外自动战斗,转化为在线自动战斗。额外功能:0延迟捕捉、自动购买高级球 // @author DreamNya // @match https://www.pokeclicker.com // @match https://g8hh.github.io/pokeclicker/ // @match https://pokeclicker.g8hh.com // @match https://yx.g8hh.com/pokeclicker/ // @icon data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/wAAAP8AAAD/AAAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AAAA/319hf99fYX/fX2F/319hf8AAAD/AAAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////////////////////99fYX/fX2F/319hf8AAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////wAAAP8AAAD/fX2F/319hf99fYX/AAAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//////8AAAD/AAAA/wAAAP99fYX/fX2F/wAAAP8AAAD/AAAA/319hf8AAAD/AAAAAAAAAAAAAAAAAAAAAAAAAP8AAAD/HBT//xwU//8AAAD//////319hf8AAAD/Dgim/w4Ipv8AAAD/AAAA/wAAAAAAAAAAAAAAAAAAAAAAAAD/HBT//xwU//8cFP//HBT//wAAAP8AAAD/Dgim/w4Ipv8OCKb/Dgim/wAAAP8AAAAAAAAAAAAAAAAAAAAAAAAA/xwU//8cFP//HBT//xwU/44cFP//HBT//xwU//8cFP//Dgim/w4Ipv8AAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/HBT//xwU/47/////HBT/jhwU//8cFP//HBT//w4Ipv8AAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/xwU//8cFP//HBT/jhwU//8OCKb/Dgim/w4Ipv8OCKb/AAAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AAAA/xwU//8OCKb/Dgim/w4Ipv8AAAD/AAAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AAAA/wAAAP8AAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//8AAPw/AADwDwAA4AcAAOAHAADAAwAAwAMAAMADAADAAwAA4AcAAOAHAADwDwAA/D8AAP//AAD//wAA//8AAA== // @grant none // @license MIT // @run-at document-end // ==/UserScript== /* eslint-env jquery */ /* global player, numberOfPokemonDefeated, GameConstants, Settings, Battle, PokeClickerHelper, NotificationConstants, DungeonBattle, MapHelper*/ if (typeof PokeClickerHelper == typeof void 0) { alert('宝可梦点击(Poke Clicker)辅助脚本 野外离线战斗模块加载失败\n\n未找到核心模块,需要先安装核心模块才可正常使用\n\n论坛主页:https://bbs.tampermonkey.net.cn/forum.php?mod=viewthread&tid=3842') window.open("https://bbs.tampermonkey.net.cn/forum.php?mod=viewthread&tid=3842") return } //劫持Game.computeOfflineEarnings const customFuc = () => { const ROUTE = player.route() //存储野外道路 PokeClickerHelper.Notify({ message: `离线期间击败了: ${numberOfPokemonDefeated.toLocaleString('en-US')} 只宝可梦\n 开始计算离线战斗……期间请勿离开当前野外道路\n预计花费:${2 * numberOfPokemonDefeated}~${5 * numberOfPokemonDefeated}ms`, timeout: 60000, type: NotificationConstants.NotificationOption.info }) let start const showCurrencyGainedAnimation = Settings.getSetting('showCurrencyGainedAnimation').value if (showCurrencyGainedAnimation) Settings.setSettingByName('showCurrencyGainedAnimation', false) //关闭货币动画 //防止移动 const moveToRoute = MapHelper.moveToRoute const moveToTown = MapHelper.moveToTown MapHelper.moveToRoute = () => { } MapHelper.moveToTown = () => { } let timer = setInterval(() => { if ($('#map').is(':visible')) { clearInterval(timer) start = Date.now() //记录载入时间 calcOffine(0, numberOfPokemonDefeated) } }, 500) function calcOffine(times, total) { let _times = Math.max(1000 - (total - times), 0) for (; _times <= 1000; _times++) { //if (App.game.breeding.eggList.find(i=>i().progress()>=100))break Battle.hook_defeatPokemon() } times += _times if (times < total) { setTimeout(() => calcOffine(times, total), 500) //下一次1000次循环 } else { const end = Date.now() //记录完成时间 if (showCurrencyGainedAnimation) Settings.setSettingByName('showCurrencyGainedAnimation', true) MapHelper.moveToRoute = moveToRoute MapHelper.moveToTown = moveToTown PokeClickerHelper.Notify({ message: `离线战斗计算完毕,现在可以正常游戏\n(测试版不保证无BUG 如有BUG欢迎反馈)\n离线计算:${numberOfPokemonDefeated}次,实际花费:${end - start}ms,平均花费${Math.floor((end - start) / numberOfPokemonDefeated)}ms`, timeout: 60000, type: NotificationConstants.NotificationOption.info }) } } }; const customText = PokeClickerHelper.HookFucBody(customFuc); const gameReplacement = [["const routeMoney = PokemonFactory.routeMoney(player.route(), player.region, false);", "if(player.route()){" + customText + "}else{const routeMoney = PokemonFactory.routeMoney(player.route(), player.region, false);"], [/$/, "}"]]; const hookGame = function (Game) { PokeClickerHelper.HookFuc(Game, 'computeOfflineEarnings', gameReplacement, ''); }; //读取野外离线战斗模块开关 let OfflineSwitch = JSON.parse(PokeClickerHelper.get('OfflineSwitch', "true")) if (OfflineSwitch) PokeClickerHelper.addHook('Game', hookGame); //劫持Battle.defeatPokemon hook野外0延迟捕捉 const defeatReplacement = [["setTimeout(() => {\n this.attemptCatch(enemyPokemon, catchRoute, region);\n if (Battle.route != 0) {\n this.generateNewEnemy();\n }\n }, App.game.pokeballs.calculateCatchTime(pokeBall));", "\n this.attemptCatch(enemyPokemon, catchRoute, region);\n if (Battle.route != 0) {\n this.generateNewEnemy();\n }\n ;"]]; PokeClickerHelper.HookFuc(Battle, 'defeatPokemon', defeatReplacement, ''); //劫持DungeonBattle.defeatPokemon hook地牢0延迟捕捉 const dungeonDefeatReplacement = [["setTimeout(() => {\n this.attemptCatch(enemyPokemon, route, region);\n if (DungeonRunner.defeatedBoss()) {\n DungeonRunner.dungeonWon();\n }\n }, App.game.pokeballs.calculateCatchTime(pokeBall));", " this.attemptCatch(enemyPokemon, route, region);\n if (DungeonRunner.defeatedBoss()) {\n DungeonRunner.dungeonWon();\n }\n ;"]]; PokeClickerHelper.HookFuc(DungeonBattle, 'defeatPokemon', dungeonDefeatReplacement, ''); //劫持Battle.prepareCatch hook自动购买高级球 const prepareCatch=[[/$/,'ItemList.Ultraball.buy(1)']] PokeClickerHelper.HookFuc(Battle, 'prepareCatch', prepareCatch, 'enemyPokemon, pokeBall'); //UI相关 const listener = () => { //真0延迟捕捉 直接把捕捉动画代码全干了【…… $('#PokeClickerHelperNoDelayCatch').on('change', function () { if (this.checked) { PokeClickerHelper.applyHook(Battle,'defeatPokemon') PokeClickerHelper.applyHook(DungeonBattle,'defeatPokemon') } else { PokeClickerHelper.restoreHook(Battle,'defeatPokemon') PokeClickerHelper.restoreHook(DungeonBattle,'defeatPokemon') } }) //自动购买高级球 $('#PokeClickerHelperBuyUltraball').on('change', function () { if (this.checked) { PokeClickerHelper.applyHook(Battle,'prepareCatch') } else { PokeClickerHelper.restoreHook(Battle,'prepareCatch') } }) $('#PokeClickerHelperNoDelayCatch').prop('checked', JSON.parse(PokeClickerHelper.get('NoDelayCatch', 'false'))).change() $('#PokeClickerHelperBuyUltraball').prop('checked', JSON.parse(PokeClickerHelper.get('BuyUltraball', 'false'))).change() $('#PokeClickerHelperOfflineSwitch').prop('checked', OfflineSwitch) } const fuc = () => { const text = `
` $("#pokeballSelectorBody thead").append(text) } PokeClickerHelper.UIContainerID.push("#PokeClickerHelperOfflineContainer"); PokeClickerHelper.UIstyle.push(`#PokeClickerHelperOfflineContainer input[type=checkbox]{position: absolute;margin-top: 0.24rem;margin-left: -1rem;}`); PokeClickerHelper.UICustomFuc.push(fuc); PokeClickerHelper.UIlistener.push(listener);